/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.vetor.model.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Moises.Moura
 */
@Entity
@Table(name = "disciplina", catalog = "dbvetor", schema = "")
@NamedQueries({
    @NamedQuery(name = "Disciplina.findAll", query = "SELECT d FROM Disciplina d"),
    @NamedQuery(name = "Disciplina.findByCodigo", query = "SELECT d FROM Disciplina d WHERE d.codigo = :codigo"),
    @NamedQuery(name = "Disciplina.findByNome", query = "SELECT d FROM Disciplina d WHERE d.nome = :nome"),
    @NamedQuery(name = "Disciplina.findByTipo", query = "SELECT d FROM Disciplina d WHERE d.tipo = :tipo")})
public class Disciplina implements Serializable {
    
    /**
	 * 
	 */
	private static final long serialVersionUID = -1994372109667882830L;
	@Id
    @Basic(optional = false)
    @Column(name = "codigo", nullable = false)
    private Integer codigo;
    
	@Column(name = "nome", length = 30)
    private String nome;
    
	@Column(name = "tipo", length = 20)
    private String tipo;
    
	@JoinTable(name = "disciplina_grade", joinColumns = {
        @JoinColumn(name = "disciplina_codigo", referencedColumnName = "codigo", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "grade_codigo", referencedColumnName = "codigo", nullable = false)})
    @ManyToMany
    private List<Grade> gradeList;
    
	@JoinTable(name = "professor_disciplina", joinColumns = {
        @JoinColumn(name = "disciplina_codigo", referencedColumnName = "codigo", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "professor_pessoa_codigo", referencedColumnName = "pessoa_codigo", nullable = false)})
    @ManyToMany
    private List<Professor> professorList;

    public Disciplina() {
    }

    public Disciplina(Integer codigo) {
        this.codigo = codigo;
    }

    public Integer getCodigo() {
        return codigo;
    }

    public void setCodigo(Integer codigo) {
        this.codigo = codigo;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public List<Grade> getGradeList() {
        return gradeList;
    }

    public void setGradeList(List<Grade> gradeList) {
        this.gradeList = gradeList;
    }

    public List<Professor> getProfessorList() {
        return professorList;
    }

    public void setProfessorList(List<Professor> professorList) {
        this.professorList = professorList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codigo != null ? codigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Disciplina)) {
            return false;
        }
        Disciplina other = (Disciplina) object;
        if ((this.codigo == null && other.codigo != null) || (this.codigo != null && !this.codigo.equals(other.codigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidadesvetor.Disciplina[codigo=" + codigo + "]";
    }

}
